// 封装所有用户相关的请求
import request from '@/utils/request.js'
/**
 *登录请求
 * @param {object} data mobile:'',code::''
 */
export const login = data => {
  return request({
    method: 'post',
    url: '/v1_0/authorizations',
    data
  })
}
/**
 *
 * @param {*} mobile 手机号
 * @returns
 */
export const sendCode = mobile => {
  return request({
    method: 'GET',
    url: '/v1_0/sms/codes/' + mobile
  })
}

export const getUserProfile = () => {
  return request({
    method: 'GET',
    url: '/v1_0/user'
  })
}

// 获取用户频道列表
export const getUserChannles = () => {
  return request({
    method: 'GET',
    url: '/v1_0/user/channels'
  })
}

/**
 *取消用户关注
 * @param {*} id
 * @returns promise
 */
export const deleteUserFollowed = id => {
  return request({
    method: 'DELETE',
    url: '/v1_0/user/followings/' + id
  })
}

/**
 *用户关注
 * @param {*} id
 * @returns promise
 */
export const addUserFollowed = id => {
  return request({
    method: 'POST',
    url: '/v1_0/user/followings',
    data: {
      target: id
    }
  })
}
